/**
*      author: Y_Yao
*      created: 2025-03-27 15:27:14
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 200 + 7;
int a[N];
int n;
int f[N][N],g[N][N];
int sum[N];

void solve()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        a[n + i] = a[i];
    }
    for(int i = 1;i <= 2 * n;i++)
    {
        sum[i] = sum[i-1] + a[i];
    }

    for(int L = 1;L <= n;L++)
    {
        for(int i = 1;i + L <= 2 * n - 1;i++)
        {
            int j = i + L;
            f[i][j] = -LLINF;
            g[i][j] = LLINF;
            for(int k = i;k < j;k++)
            {
                f[i][j] = max(f[i][j],f[i][k] + f[k+1][j]);
                g[i][j] = min(g[i][j],g[i][k] + g[k+1][j]);
            }
            f[i][j] += sum[j] - sum[i-1];
            g[i][j] += sum[j] - sum[i-1];
        }
    }
    int ans1 = LLINF,ans2 = -LLINF;
    for(int i = 1;i <= n;i++)
    {
        ans1 = min(ans1,g[i][i+n-1]);
        ans2 = max(ans2,f[i][i+n-1]);
    }
    cout << ans1 << endl;
    cout << ans2 << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}